
import java.util.*;
public class Solution
{
    public String compressString (String param)
    {
        StringBuffer ret = new StringBuffer();
        char[] s = param.toCharArray();
        int left = 0, right = 0, n = s.length;
        while(left < n)
        {
            while(right + 1 < n && s[right + 1] == s[right])
                right++;
            int len = right - left + 1;
            ret.append(s[left]);
            if(len > 1) {
            ret.append(len);
            }
            left = right + 1;
            right = left;
        }
        return ret.toString();
    }
}
